<extend name="Layout/ins_page" />
<block name="content">
   <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>



        <legend><span></span></legend>
        <div  id='fm1'>
        <div class="fieldset-body">
        
     <span>过账日期：</span>
		<input id="start" class="mini-datepicker"  format="yyyy-MM-dd "  showTime="true" valueType='string' value="<?php echo date('Y-m-d',time()-86400)?>"/>
		-<input id="end" class="mini-datepicker"  format="yyyy-MM-dd "  showTime="true" valueType='string' value="<?php echo date('Y-m-d ')?>" /> 
		 <span>客户/供应商名称</span>
		<input  class="mini-textbox" id='CardName'  />
		 <span>物料编号</span>
		<input  class="mini-textbox" id='ItemCode'  /><br/><br/>
		 <span>物料/服务描述</span>
		<input  class="mini-textbox" id='Dscription'  />
		
		 <span>销售代表姓名</span>
		<input  class="mini-textbox" id='CGY'  />
		
		 <span>单据编号</span>
		<input  class="mini-textbox" id='DocNum' />
        
        <span>单据状态：</span>
		<input id="DocStatus"  style='width:15.3%;margin-left: -3.6px' class="mini-combobox" style="width:150px;" textField="text" valueField="id" 
    data='[
		{ "id": "NO", "text": "未清" },
		{ "id": "NC", "text": "已清" },
		{ "id": "YC", "text": "已取消" },
		]' value="" showNullItem="true" required="true" allowInput="true"
    
/>  
		
		
	
	<br/>
    <a class="mini-button" onclick="search()" enabled="" id='query-bt'  style="margin-top: 5px">&nbsp;&nbsp;查询&nbsp;&nbsp;</a> 
 
  
   
    <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
    buttons="#tabsButtons"
>
    <div title="查询结果" >
   
   <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;" 
        url="/warehouse/getreceiptData" idField="id" showPager='false'
        allowResize="true" 
        allowCellEdit="true" allowCellSelect="true" multiSelect="true"
        allowCellValid="true" oncellvalidation="" 
    >
    
        <div property="columns">
           
             <div field="docstatus"  headerAlign="center"  >单据状态
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="isClose"  headerAlign="center"  >是否已关闭
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
             <div field="DocNum"  headerAlign="center"  >单据编号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="CardCode"  headerAlign="center"  >客户/供应商代码
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="CardName"  headerAlign="center"  >客户/供应商名称
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="NumAtCard"  headerAlign="center"  >客户/供应商参考编号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="CGY"  headerAlign="center"  >采购员
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="TaxDate"  headerAlign="center"  >单据日期
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
           <div field="JHDate"  headerAlign="center"  >交货日期
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
           <div field="ItemCode"  headerAlign="center"  >物料编号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
           <div field="Dscription"  headerAlign="center"  >物料/服务描述
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
           <div field="Quantity"  headerAlign="center"  >数量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="OPENQTY"  headerAlign="center"  >剩余未清数量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="CGPrice"  headerAlign="center"  >采购单价
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="OPENPrice"  headerAlign="center"  >未清金额总计
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="CLOSEPrice"  headerAlign="center"  >已清金额总计
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
          
        </div>
    </div>
    
    </div>
    <!-- <div title="Tab2" iconCls="" >
        2
    </div> -->
</div>
</div>
</div>


</body>
<script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;

            //格式化日期
            if (field == "TaxDate"||field=='JHDate') {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
				
            }

            if (field == "Quantity"||field=='OPENQTY') {
               var tempNumber = parseInt(value);
               if(!isNaN(tempNumber)){
            	   e.cellHtml = tempNumber;
               }else{
            	   e.cellHtml = 0;
               }
            }
          
            if (field == "OPENPrice"||field=='CLOSEPrice') {
                var tempNumber = parseFloat(value);
                if(!isNaN(tempNumber)){
             	   e.cellHtml = tempNumber;
                }else{
             	   e.cellHtml = '0.00';
                }
             }
            
            if (field == "ItemCode") {
                e.cellHtml = '<a id="' + value + '" class="showCellTooltip" data-placement="bottomleft">' +value+ '</a>';
            }
            

        });

        function search(){
        	var start = mini.get('start').getValue();
        	var end   = mini.get('end').getValue();
        	var cardName = mini.get('CardName').getValue();
        	var itemCode = mini.get('ItemCode').getValue();
        	var dscription = mini.get('Dscription').getValue();
        	var CGY = mini.get('CGY').getValue();
        	var docNum = mini.get('DocNum').getValue();
			var DocStatus = mini.get("DocStatus").getValue();
        	grid.load({start:start,end:end,cardName:cardName,itemCode:itemCode,dscription:dscription,cgy:CGY,docNum:docNum,DocStatus:DocStatus})
        }
       

        
     
	var box;
	jQuery('.showCellTooltip').live('click', function() {
		mini.hideMessageBox(box);
		
		mini.mask({
			el : document.body,
			cls : 'mini-mask-loading',
			html : '加载库存信息..'
		});
		
		var id = jQuery(this).html();
		$.ajax({
			url : "/sap/getware.php",
			data : {
				id : id
			},
			async : true,
			success : function(text) {
				mini.unmask(document.body);
				htmlClick(text);

			}
		});
	})

	function htmlClick(htmlContent) {
		box = mini.showMessageBox({
			width : 550,
			title : "库存情况",
			html : htmlContent,
			showModal : false,
		});
	}
</script>
    </block>

